package org.zhxy.core.personnel.controller;


import org.springframework.web.bind.annotation.*;
import org.zhxy.common.aop.AutomaticLog;
import org.zhxy.common.config.ServiceFactory;
import org.zhxy.common.error.CommonException;
import org.zhxy.common.response.Result;
import org.zhxy.entity.personnel.UserTeacher;

import java.util.Map;

@RestController
@RequestMapping("/teacher")
public class TeacherController {

    @RequestMapping(value = "/searchTeacherList",method = RequestMethod.POST)
    public Result searchTeacherList(@RequestBody Map<String, Object> map) throws CommonException {
        return Result.SUCCESS_NO_MESSAGE(ServiceFactory.teacherService.searchTeacherList(map));
    }

    //@AutomaticLog("通过部门ID查询部门教师集合")
    @RequestMapping(value = "/searchTeachersByDepartment/{departmentId}",method = RequestMethod.GET)
    public Result searchTeachersByDepartment(@PathVariable("departmentId")String departmentId){
        return Result.SUCCESS_NO_MESSAGE(ServiceFactory.teacherService.searchTeachersByDepartment(departmentId));
    }

    //@AutomaticLog("根据条件查询教师")
    @RequestMapping(value = "/searchTeacher",method = RequestMethod.POST)
    public Result searchTeacher(@RequestBody Map<String, Object> map){
        return Result.SUCCESS_NO_MESSAGE(ServiceFactory.teacherService.searchTeacher(map));
    }

    @AutomaticLog("修改教师")
    @RequestMapping(value = "/updateTeacher",method = RequestMethod.POST)
    public Result updateTeacher(@RequestBody UserTeacher userTeacher){
        return ServiceFactory.teacherService.updateTeacher(userTeacher);
    }

    @AutomaticLog("根据登陆者id查询当前登陆者信息")
    @RequestMapping(value = "/searchTeacherBySelf",method = RequestMethod.GET)
    public Result searchTeacherBySelf(){
        return Result.SUCCESS_NO_MESSAGE(ServiceFactory.teacherService.searchTeacherBySelf());
    }


    @AutomaticLog("查询教员及班主任集合")
    @RequestMapping(value = "/searchTeachers",method = RequestMethod.GET)
    public Result searchTeachers(){
        return Result.SUCCESS_NO_MESSAGE(ServiceFactory.teacherService.searchTeachers());
    }
}
